package com.chenjt.netty.eight_nio.simple;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * 注释：
 *
 * @author chenjt
 * @date 2024/8/20 10:13
 */
public class NioTest2 {


    public static void main(String[] args) throws Exception {

        FileInputStream fileInputStream = new FileInputStream("src/main/java/com/chenjt/netty/eight_nio/simple/NioTest2.txt");
        FileChannel fileChannel = fileInputStream.getChannel();

        ByteBuffer byteBuffer = ByteBuffer.allocate(512);
        fileChannel.read(byteBuffer);

        byteBuffer.flip();

        // 读取项目根目录中 NioTest2.txt 文件中的所有内容
        while(byteBuffer.remaining() > 0){
            byte b = byteBuffer.get();
            System.out.println("Character:" + (char)b);
        }

        fileInputStream.close();

    }

}
